package com.lagou.util;

/**
 * @Authther: mrwu
 * @date:2021/3/13-03
 * @Description:com.lagou.util
 */

import com.lagou.annotion.Autowired;
import com.lagou.annotion.Comppent;

/**
 * 事务管理器类 //相当于aop中的切面类
 */
@Comppent //修改为注解模式
public class TransactionManager implements PlatformTrancationManager {
    //单例模式下
//    private static TransactionManager transactionManager = new TransactionManager();
//
//    public static TransactionManager getTransactionManager() {
//        return transactionManager;
//    }
//    private TransactionManager() {
//    }
    @Autowired
    private SqlsssionUtils sqlsssionUtils;

    public void setSqlsssionUtils(SqlsssionUtils sqlsssionUtils) {
        this.sqlsssionUtils = sqlsssionUtils;
    }



    //提交事务
    public void commit(){
//        SqlsssionUtils.getInstance().getCurrentSqlsssion().commit();
        sqlsssionUtils.getCurrentSqlsssion().commit();
    }
    //回滚事务
    public void rollback(){
//        SqlsssionUtils.getInstance().getCurrentSqlsssion().rollback();
        sqlsssionUtils.getCurrentSqlsssion().rollback();
    }

}
